package com.zpark.se.thread;

/**
 * @PackageName: com.zpark.se.thread
 * @ClassName: Demo07
 * @Description:
 * @author: RZS
 * @date: 2024/11/26  17:42
 */
public class Demo07 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new MyThread();
        t.start();
        Thread.sleep(1); // 暂停主线程，1毫秒
        t.interrupt(); // 中断t线程
        t.join(); // 等待t线程结束

        System.out.println("end");
    }
}


class MyThread extends Thread {
    public void run() {
        int n = 0;
        while (! super.isInterrupted()) {
            n ++;
            System.out.println(n + " hello!");
        }
    }
}
